<form id="<?php echo $uniqid;?>" method="post" style="padding: 8px;">
    <table border="0" width="100%" cellspacing="1" cellpadding="5" class="formtable">
        <tr bgcolor="#FFFFFF">
            <td class="tlabel">区域代理申请ID：</td>
            <td width="80%">{{params.id}}</td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel">代理类型：</td>
            <td width="80%">{{params.mode==='xianqu'?'县区代理':'市级代理'}}</td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel">申请区域：</td>
            <td width="80%">{{params.area_name}}</td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel">区域代理申请人ID：</td>
            <td width="80%">{{params.member_id}}</td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel">区域代理申请企业名称：</td>
            <td width="80%">{{params.company_name}}</td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel">代理费用金额：</td>
            <td width="80%">
                <el-input-number size="small" v-model="params.agent_fee"></el-input-number></td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel">支付类型：</td>
            <td width="80%">
                <label><input name="pay_type" type="radio" class="textbox-prompt" v-model="payType" :value="0">线下支付</label>
                <label><input name="pay_type" type="radio" class="textbox-prompt" v-model="payType" :value="1">订单支付</label>
            </td>
        </tr>
        <tr bgcolor="#FFFFFF" v-if="payType === 1">
            <td  class="tlabel" >订单ID：</td>
            <td width="80%">
                <input type="text" style="width:300px;" v-model="params.agent_fee_payed_id"
                                   class="forminput inputstyle textbox-text validatebox-text textbox-prompt easyui-validatebox"
                                   placeholder="请输入订单ID.." readonly>
                <span class="l-btn l-btn-small" style="margin-left: 5px;" @click="getOrder"><span class="l-btn-text">{{params.agent_fee_payed_id>0?'更换订单':'设置订单'}}</span></span>

            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel">支付状态：</td>
            <td width="80%">
                <label><input name="status" type="radio" class="textbox-prompt" v-model="params.agent_fee_pay_status" :value="0">未支付</label>
                <label><input name="status" type="radio" class="textbox-prompt" v-model="params.agent_fee_pay_status" :value="1">已支付</label>
                <label><input name="status" type="radio" class="textbox-prompt" v-model="params.agent_fee_pay_status" :value="-1">已退回</label>
            </td>
        </tr>
    </table>
</form>
<div id="qudaiapplyfeeeditdlg" class="easyui-dialog" style="width:840px; height:520px;" title="信息框" closed="true"></div>
<script>
    var qudaiapplyFeeEditVm = new Vue({
        el: '#<?php echo $uniqid;?>',
        data: {
            params: JSON.parse('<?php echo addslashes($dataset);?>'),
            submitParams:{
                id:0,
                agent_fee:0.00,
                agent_fee_pay_status:'',
                agent_fee_payed_id:'',
            },
            payType:0
        },
        mounted: function (){
            let that = this;
            if(that.params.agent_fee_payed_id === -1){
                that.payType = 0;
            }else{
                that.payType = 1;
            }
        },
        methods: {
            submit: function () {
                if(this.params.id <= 0){
                    $.messager.alert('提示', '参数出错', 'warning');
                    $("#qudaiapplydlg").dialog('close');
                    return;
                }
                if(this.params.agent_fee <= 0){
                    $.messager.alert('提示', '代理费用不能小于0', 'warning');
                    return;
                }
                if(this.payType === 0){
                    this.submitParams.agent_fee_payed_id = -1;
                }else{
                    this.submitParams.agent_fee_payed_id = this.params.agent_fee_payed_id;
                }
                this.submitParams.id = this.params.id;
                this.submitParams.agent_fee = this.params.agent_fee;
                this.submitParams.agent_fee_pay_status = this.params.agent_fee_pay_status;
                $.post('/admin/qudaiapply/feeedit', this.submitParams, function (data) {
                    if (data.ret === 0) {
                        $.messager.show({
                            title: '提示',
                            msg: data.msg,
                            timeout: 3000,
                            showType: 'slide'
                        });
                        $('#<?php echo $uniqid;?>').form('clear');
                        $("#qudaiapplydlg").dialog('close');
                        qudaiapplyReload(true);
                    } else {
                        $.messager.alert('提示', data.msg, 'warning');
                    }
                }, 'json');
            },
            getOrder:function (){
                if(this.params.member_id){
                    $("#qudaiapplyfeeeditdlg").dialog({
                        title: `用户ID:${this.params.member_id} 的订单列表`,
                        closed: false,
                        width: 960,
                        height: 560,
                        cache: false,
                        href: '/admin/qudaiapply/getorder?id=' + this.params.member_id,
                        modal: true,
                        buttons: [{
                            text: '确定',
                            id: 'qudaiapplyFeeEditOrdersubmit',
                            iconCls: 'icon-ok',
                        }, {
                            text: '关闭',
                            iconCls: 'icon-no',
                            handler: function () {
                                $("#qudaiapplyfeeeditdlg").dialog('close');
                            }
                        }]
                    });
                }else{
                    $.messager.alert('提示', '无效店铺申请','warning');
                }
            },
        }
    });
    $(function () {
        $('#qudaiapplyFeeEditsubmit').click(function (data) {
            qudaiapplyFeeEditVm.submit();
        });
    });
</script>
